#include <iostream>
using namespace std;

class Base {
public:
    int data1;
};

class Sub : public Base {
public:
    int data2;
};

int main() {
    Base * b = new Base();
    b->data1 = 3;
    Sub * sub = static_cast<Sub *>(b);
    cout << sub->data1 << endl << sub->data2 << endl;
    Sub * sub2 = new Sub();
    sub2->data1 = sub2->data2 = 2;
    Base * b2 = dynamic_cast<Base *>(sub2);
    cout << b2->data1 << endl;
}
